package com.ds.springbootmybatis.controller;

import com.ds.springbootmybatis.mapper.EmployeeMapper;
import com.ds.springbootmybatis.pojo.Employee;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @program: SpringBoot
 * @description:
 * @author: Dawson.Zhang
 * @create: 2020-05-13
 **/
@RestController
public class EmployeeController {
    @Resource
    EmployeeMapper employeeMapper;

    @GetMapping("/emp/{id}")
    public Employee getByid(@PathVariable("id")Integer id){
        Employee byId = employeeMapper.getById(id);
        return byId;
    }
    @GetMapping("/emps")
    public List<Employee> getAll(){
        List<Employee> all = employeeMapper.getAll();
        return all;
    }
    @PutMapping("/emp")
    public Employee addEmp(Employee employee){
        Integer add = employeeMapper.add(employee);
        return employee;
    }
}
